package com.accounting.client.frontend.common;

import com.accounting.client.remote.enumeration.Currency;

import corelib.client.NumberFormats;
import corelib.client.ui.widget.WidgetListener;
import corelib.client.ui.widget.form.DecimalBox;

public class CurrencyBox extends DecimalBox {
	
	public CurrencyBox() {
		super(1, WidgetListener.Nil);
	}
	
	public CurrencyBox(Currency currency) {
		super(1, WidgetListener.Nil);
		setCurrency(currency);
	}
	
	public CurrencyBox(WidgetListener l) {
		super(l);
	}
	
	public CurrencyBox(Currency currency, WidgetListener l) {
		super(l);
		setCurrency(currency);
	}
	
	@Override
	protected void init() {
		super.init();
		setEmptyText("$");
		setFormat(NumberFormats.AUD);	
	}
	
	public void setCurrency(Currency currency){
		setEmptyText("$");
		if (currency == Currency.RMB){
			setFormat(NumberFormats.RMB);
		}
		else {
			setFormat(NumberFormats.AUD);
		}
	}
	
}
